/*******************************************************************************
 * NAME
 *        det4 - determinant of a 4 by 4 matrix
 *
 * SYNOPSIS
 *        #include <mcce.h>
 *
 *        float det4(float m[][4]);
 *
 * DESCRIPTION
 *        The det4() function returns the determinant of a 4 by 4 matrix.
 *
 * SEE ALSO
 *        det3
 *
 * EXAMPLE
 *        float det;
 *        float M[4][4];
 *        ...
 *        det = det4(M);
 *
 * AUTHOR
 *        Junjun Mao, 05/26/2003
 *******************************************************************************/

float det4(float m[][4])
{  return (m[0][0] * m[1][1] - m[0][1] * m[1][0]) * (m[2][2] * m[3][3] - m[2][3] * m[3][2])
        - (m[0][0] * m[1][2] - m[0][2] * m[1][0]) * (m[2][1] * m[3][3] - m[2][3] * m[3][1])
        + (m[0][0] * m[1][3] - m[0][3] * m[1][0]) * (m[2][1] * m[3][2] - m[2][2] * m[3][1])
        + (m[0][1] * m[1][2] - m[0][2] * m[1][1]) * (m[2][0] * m[3][3] - m[2][3] * m[3][0])
        - (m[0][1] * m[1][3] - m[0][3] * m[1][1]) * (m[2][0] * m[3][2] - m[2][2] * m[3][0])
        + (m[0][2] * m[1][3] - m[0][3] * m[1][2]) * (m[2][0] * m[3][1] - m[2][1] * m[3][0]);
}
